package com.cong.taoyao.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.io.File;

@Controller
public class HomeController {

    @GetMapping("/")
    public String home(Model model) {
        // 获取项目根目录下的templates目录
        String uploadDir = "src/main/resources/templates/";

        // 获取文件列表
        File[] files = new File(uploadDir).listFiles();

        // 将文件列表传递给前端
        model.addAttribute("files", files);

        return "index";
    }

    @GetMapping("/preview")
    public String preview() {
        return "preview";
    }
}
